<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Doxygen: common/include/pcl/common/file_io.h 文件参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Doxygen
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'搜索','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('common_2include_2pcl_2common_2file__io_8h.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">函数</a>  </div>
  <div class="headertitle">
<div class="title">file_io.h 文件参考<div class="ingroups"><a class="el" href="group__common.html">Common components</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;iostream&gt;</code><br />
<code>#include &lt;dirent.h&gt;</code><br />
<code>#include &lt;vector&gt;</code><br />
<code>#include &lt;algorithm&gt;</code><br />
<code>#include &lt;pcl/common/impl/file_io.hpp&gt;</code><br />
</div>
<p><a href="common_2include_2pcl_2common_2file__io_8h_source.html">浏览源代码.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:a65492f5cdc563cd60c2267366788d077"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_2include_2pcl_2common_2file__io_8h.html#a65492f5cdc563cd60c2267366788d077">pcl::getAllPcdFilesInDirectory</a> (const std::string &amp;directory, std::vector&lt; std::string &gt; &amp;file_names)</td></tr>
<tr class="memdesc:a65492f5cdc563cd60c2267366788d077"><td class="mdescLeft">&#160;</td><td class="mdescRight">Find all *.pcd files in the directory and return them sorted  <a href="common_2include_2pcl_2common_2file__io_8h.html#a65492f5cdc563cd60c2267366788d077">更多...</a><br /></td></tr>
<tr class="separator:a65492f5cdc563cd60c2267366788d077"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a77fba9b71d0b5ddc824cc3555c258513"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_2include_2pcl_2common_2file__io_8h.html#a77fba9b71d0b5ddc824cc3555c258513">pcl::getFilenameWithoutPath</a> (const std::string &amp;input)</td></tr>
<tr class="memdesc:a77fba9b71d0b5ddc824cc3555c258513"><td class="mdescLeft">&#160;</td><td class="mdescRight">Remove the path from the given string and return only the filename (the remaining string after the last '/')  <a href="common_2include_2pcl_2common_2file__io_8h.html#a77fba9b71d0b5ddc824cc3555c258513">更多...</a><br /></td></tr>
<tr class="separator:a77fba9b71d0b5ddc824cc3555c258513"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af45ced9a4448cf680b2e5da96f4e9aea"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_2include_2pcl_2common_2file__io_8h.html#af45ced9a4448cf680b2e5da96f4e9aea">pcl::getFilenameWithoutExtension</a> (const std::string &amp;input)</td></tr>
<tr class="memdesc:af45ced9a4448cf680b2e5da96f4e9aea"><td class="mdescLeft">&#160;</td><td class="mdescRight">Remove the extension from the given string and return only the filename (everything before the last '.')  <a href="common_2include_2pcl_2common_2file__io_8h.html#af45ced9a4448cf680b2e5da96f4e9aea">更多...</a><br /></td></tr>
<tr class="separator:af45ced9a4448cf680b2e5da96f4e9aea"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae40c9e0ff704ed675e3300ed02451796"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="common_2include_2pcl_2common_2file__io_8h.html#ae40c9e0ff704ed675e3300ed02451796">pcl::getFileExtension</a> (const std::string &amp;input)</td></tr>
<tr class="memdesc:ae40c9e0ff704ed675e3300ed02451796"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the file extension from the given string (the remaining string after the last '.')  <a href="common_2include_2pcl_2common_2file__io_8h.html#ae40c9e0ff704ed675e3300ed02451796">更多...</a><br /></td></tr>
<tr class="separator:ae40c9e0ff704ed675e3300ed02451796"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p>Define some helper functions for reading and writing files</p>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000003">待办事项:</a></b></dt><dd>move this to pcl::console </dd></dl>
</div><h2 class="groupheader">函数说明</h2>
<a id="a65492f5cdc563cd60c2267366788d077"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a65492f5cdc563cd60c2267366788d077">&#9670;&nbsp;</a></span>getAllPcdFilesInDirectory()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void pcl::getAllPcdFilesInDirectory </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>directory</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::vector&lt; std::string &gt; &amp;&#160;</td>
          <td class="paramname"><em>file_names</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Find all *.pcd files in the directory and return them sorted </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">directory</td><td>the directory to be searched </td></tr>
    <tr><td class="paramname">file_names</td><td>the resulting (sorted) list of .pcd files </td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;  {</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    DIR *dp;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    <span class="keyword">struct </span>dirent *dirp;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    <span class="keywordflow">if</span>((dp  = opendir(directory.c_str())) == NULL) {</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;      std::cerr &lt;&lt; <span class="stringliteral">&quot;Could not open directory.\n&quot;</span>;</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;      <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;    }</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    <span class="keywordflow">while</span> ((dirp = readdir(dp)) != NULL) {</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;      <span class="keywordflow">if</span> (dirp-&gt;d_type == DT_REG)  <span class="comment">// Only regular files</span></div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;      {</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        std::string file_name = dirp-&gt;d_name;</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        <span class="keywordflow">if</span> (file_name.substr(file_name.size()-4, 4)==<span class="stringliteral">&quot;.pcd&quot;</span>)</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;          file_names.push_back(dirp-&gt;d_name);</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;      }</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    }</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    closedir(dp);</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    std::sort(file_names.begin(), file_names.end());</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    <span class="comment">//for (unsigned int i=0; i&lt;file_names.size(); ++i)</span></div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;      <span class="comment">//cout &lt;&lt; file_names[i]&lt;&lt;&quot;\n&quot;;</span></div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  }</div>
</div><!-- fragment -->
</div>
</div>
<a id="ae40c9e0ff704ed675e3300ed02451796"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae40c9e0ff704ed675e3300ed02451796">&#9670;&nbsp;</a></span>getFileExtension()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::string pcl::getFileExtension </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>input</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get the file extension from the given string (the remaining string after the last '.') </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>the input filename </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd><em>input</em> 's file extension </dd></dl>
<div class="fragment"><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;{</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;  <span class="keywordtype">size_t</span> dot_position = input.find_last_of(<span class="charliteral">&#39;.&#39;</span>, input.size());</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;  <span class="keywordflow">return</span> input.substr(dot_position+1, input.size());</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="af45ced9a4448cf680b2e5da96f4e9aea"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af45ced9a4448cf680b2e5da96f4e9aea">&#9670;&nbsp;</a></span>getFilenameWithoutExtension()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::string pcl::getFilenameWithoutExtension </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>input</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Remove the extension from the given string and return only the filename (everything before the last '.') </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>the input filename (with the file extension) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>the resulting filename, stripped of its extension </dd></dl>
<div class="fragment"><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;{</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;  <span class="keywordtype">size_t</span> dot_position = input.find_last_of(<span class="charliteral">&#39;.&#39;</span>, input.size());</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;  <span class="keywordflow">return</span> input.substr(0, dot_position);</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a77fba9b71d0b5ddc824cc3555c258513"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a77fba9b71d0b5ddc824cc3555c258513">&#9670;&nbsp;</a></span>getFilenameWithoutPath()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::string pcl::getFilenameWithoutPath </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>input</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Remove the path from the given string and return only the filename (the remaining string after the last '/') </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>the input filename (with full path) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>the resulting filename, stripped of the path </dd></dl>
<div class="fragment"><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;{</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;  <span class="keywordtype">size_t</span> filename_start = input.find_last_of(<span class="charliteral">&#39;/&#39;</span>, <span class="keyword">static_cast&lt;</span><span class="keywordtype">size_t</span><span class="keyword">&gt;</span>(-1)) + 1;</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;  <span class="keywordflow">return</span> input.substr(filename_start, input.size()-filename_start);</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_bdd9a5d540de89e9fe90efdfc6973a4f.html">common</a></li><li class="navelem"><a class="el" href="dir_11fbc4217d50ab21044e5ad6614aede5.html">include</a></li><li class="navelem"><a class="el" href="dir_39ef148c3cf3468c290ae8c03b3c03af.html">pcl</a></li><li class="navelem"><a class="el" href="dir_474708a720ff06817ce2c12e28baf137.html">common</a></li><li class="navelem"><a class="el" href="common_2include_2pcl_2common_2file__io_8h.html">file_io.h</a></li>
    <li class="footer">制作者 <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
